import axios from 'axios'
import api from "@/utils/request";

const API_BASE_URL = 'http://localhost:8080/api'


export const listFiles = async (path: string) => {
    return api.get('/documentManager/sftp/files/list?path=' + path)
}

export const downloadFile = async (path: string) => {
    return api.get('/documentManager/sftp/files/download?filePath=' + path)
}


export const uploadFile = async (path: string, file: File) => {
    const formData = new FormData()
    formData.append('file', file)
    formData.append('path', path)

    const response = await axios.post(`${API_BASE_URL}/files/upload`, formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
    return response.data
}